#!/bin/bash

case $BLOCK_BUTTON in
    1) python3.6 ~/.scripts/networkmanager_dmenu ;;
esac

INTERFACE="${BLOCK_INSTANCE:-wlp1s0}"

[[ "$(cat /sys/class/net/$INTERFACE/operstate)" = 'down' ]] && echo 📡 && exit

QUALITY=$(grep $INTERFACE /proc/net/wireless | awk '{ print int($3 * 100 / 70) }')

echo 📶 $QUALITY%

color
if [[ $QUALITY -ge 80 ]]; then
    echo "#00FF00"
elif [[ $QUALITY -lt 80 ]]; then
    echo "#FFF600"
elif [[ $QUALITY -lt 60 ]]; then
    echo "#FFAE00"
elif [[ $QUALITY -lt 40 ]]; then
    echo "#FF0000"
fi
